//
//  TextFieldDefaultStyle.m
//  UILbrary
//
//  Created by mac on 16/7/18.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "TextFieldDefaultStyle.h"
#import "CustomTextField.h"
#import "Constant.h"
@interface TextFieldDefaultStyle ()<UITextFieldDelegate>

@end
@implementation TextFieldDefaultStyle
- (void)viewDidLoad{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self createTextField];
}

- (void)createTextField{
    CustomTextField *textField = [[CustomTextField alloc] initWithFrame:CGRectMake(10, 300, kAPP_With-20, 80)];
    textField.borderStyle = UITextBorderStyleRoundedRect;
    textField.delegate = self;
    textField.backgroundColor = [UIColor orangeColor];
    textField.layer.cornerRadius = 5;
    //左视图
    UILabel *leftLable = [[UILabel alloc] initWithFrame:CGRectMake(100, 10, 200, 100)];
    leftLable.backgroundColor = [UIColor redColor];
    leftLable.text = @"这是UITextFiel的左视图";
    textField.leftView = leftLable;
    textField.leftViewMode = UITextFieldViewModeAlways;
    
    //右视图
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    button.backgroundColor = [UIColor blueColor];
    [button setTitle:@"这是TextFiel的右视图" forState:UIControlStateNormal];
    textField.rightView = button;
    textField.rightViewMode = UITextFieldViewModeAlways;
    [self.view addSubview:textField];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}
@end
